import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const routes = [
    // 路由重定向
    {
        path: "/",
        redirect: "/index/list"
    },
    //首页路由
    {
        path: "/index",
        name: "index",
        component: () =>
            import ("@/pages/home/index"),
        children: [{
                path: "list",
                name: "list",
                component: () =>
                    import ("@/pages/home/children/homeList"),
            },
            {
                path: "detail",
                name: "detail",
                component: () =>
                    import ("@/pages/home/children/goodsDetails")
            }
        ]
    },
    // 订单
    {
        path: "/order",
        name: "order",
        component: () =>
            import ("@/pages/order/index"),
        children: [{
                path: "list",
                name: "list",
                component: () =>
                    import ("@/pages/order/children/orderList"),
            },
            {
                path: "detail", //wujinkun
                name: "detail",
                component: () =>
                    import ("@/pages/order/children/detail"),
            },
            {
                path: "submitOrder",
                name: "submitOrder",
                component: () =>
                    import ("@/pages/order/children/submitOrder"),
            },
            {
                path: "myOrder", //wujinkun
                name: "myOrder",
                component: () =>
                    import ('@/pages/order/children/myOrder')
            }
        ]
    },
    //商品的类型
    {
        path: "/type",
        name: "type",
        redirect: '/type/list',
        component: () =>
            import ("@/pages/type/index"),
        children: [{
            path: "list",
            name: "type-list",
            component: () =>
                import ("@/pages/type/children/list"),
        }]

    },
    {
        //购物车
        path: "/car",
        name: "car",
        component: () =>
            import ("@/pages/cart/index"),
        children: [{
                path: "status",
                name: "status",
                component: () =>
                    import ("@/pages/cart/carStatus")
            },
            {
                path: "edit",
                name: "edit",
                component: () =>
                    import ("@/pages/cart/editCarStatus")
            }
        ]
    },
    {
        //支付
        path: "/pay",
        name: "pay",
        component: () =>
            import ("@/pages/pay/pay")
    },
    {
        //地址路由
        path: "/address",
        name: "address",
        component: () =>
            import ("@/pages/address/index"),
        children: [{
                path: "add",
                name: "add",
                component: () =>
                    import ("@/pages/address/addressAdd")
            },
            {
                path: "edit",
                name: "edit",
                component: () =>
                    import ("@/pages/address/addressEdit")
            },
            {
                path: "list",
                name: "list",
                component: () =>
                    import ("@/pages/address/addressList")
            },
        ]
    },

    {
        //个人中心
        path: "/my",
        name: "my",
        component: () =>
            import ("@/pages/my/index"),
        children: [{
                path: "center",
                name: "center",
                component: () =>
                    import ("@/pages/my/children/center")
            },
            {
                path: "set",
                name: "set",
                component: () =>
                    import ("@/pages/my/children/mySet")
            }
        ]

    },
    {
        //登录路由
        path: "/login",
        name: "login",
        component: () =>
            import ("@/pages/login/login")
    },

    {
        //注册路由
        path: "/register",
        name: "register",
        component: () =>
            import ("@/pages/register/register")
    },
    {
        //访问页面失败
        path: "/notfound",
        name: "notfound",
        component: () =>
            import ("@/components/NotFound")

    },
    // 测试
    {
        path: "/demo",
        name: "demo",
        component: () =>
            import ("@/pages/demo/demo")
    }
]

export default new Router({
    routes
})